package com.example.nettyparseinner.future;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * author :sherlock.lin
 * date : Created in 2023/2/8
 * description :
 */

public class TestJdkFuture {
    private static final Logger LOG = LoggerFactory.getLogger(TestJdkFuture.class);

    public static void main(String[] args) throws Exception{
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> future = service.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                LOG.debug("执行计算");
                Thread.sleep(2000);
                return 50;
            }
        });

        LOG.debug("等待结果");
        LOG.debug("结果是 {}", future.get());
    }
}
